<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>War</title>
  	<link href="dist/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="static/css/style.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="static/js/jquery.js"></script>
	<style>
		.margin-top{
			padding-top:7px;
			font-size:14px;
		}
	</style>
	<script>
		var a = 59;
		var tim;
		$(function(){
			//用来记录验证码
			var yyy = "a";
			//获取验证码
			$("#ph").click(function(){
				$.post("system/goPhone",{phone:$("[name=hUserphone]").val()},function(date){
					if(date==1){
						$("#shoujihao").html("");
						$.post("system/sengcheng",function(date){yyy=date});
						dian();
					}else{
						$("#shoujihao").html("手机号错误!!!");
					}
				});
				
			});
			//旧密码失焦事件
			$("[name=aaa]").blur(function(){
				var ta = $(this).val();
				if(ta==""){
					$("#jiu").html("旧密码不能为空!!!");
				}else{
					$("#jiu").html("");
				}
			});
			//验证码不能为空
			$("[name=Yanzheng]").blur(function(){
				var tb = $(this).val();
				if(tb==""){
					$("#Y").html("验证码不能为空!!!");
				}else{
					$("#Y").html("");
				}
			});
			//新密码不能为空
			$("[name=hUserpassword]").blur(function(){
				var tc = $(this).val();
				if(tc==""){
					$("#x").html("密码不能为空!!!");
				}else if(tc.length<6){
					$("#x").html("密码不能小于6位!!!");
				}else{
					$("#x").html("");
				}
			});
			$("#queding").click(function(){
				//获取旧密码
				var aaa = $("[name=aaa]").val();
				//获取验证码
				var bbb = $("[name=Yanzheng]").val();
				//获取新密码
				var ccc = $("[name=hUserpassword]").val();
				$.post("system/goPassword",{password:aaa},function(date){
					if(date==1){
						$("#jiu").html("");
						if(bbb==yyy){
							$("#Y").html("");
							if(ccc!=""){
								$("#x").html("");
								alert("成功");
							}else if(ccc==""){
								$("#x").html("密码不能为空!!!");
							}else{
								$("#x").html("密码不能小于6位!!!");
							}
						}else{
							$("#Y").html("验证码错误!!!");
						}
					}else{
						$("#jiu").html("旧密码错误!!!");
					}
				});
			});
		});
		function dian(){
			a = 59;
			$("#ph").unbind("click");
			$("#ph").html(a+"秒后重发");
			tim = setInterval(function(){ta();},1000);
		}
		function ta(){
			a--;
			$("#ph").html(a+"秒后重发");
			if(a<1){
				yyy="a";
				$("#ph").html("获取验证码");
				$("#ph").bind("click",function(){dian();});
				clearTimeout(tim);
			}
		}
	</script>
</head>

<body>
	<div class="place">
	    <span>位置：</span>
	    <ul class="placeul">
		    <li><a href="#">首页</a></li>
		    <li><a href="#">表单</a></li>
	    </ul>
    </div>
    <div class="formbody">
    	<div class="formtitle"><span>修改密码</span></div>
	    	<form  class="form-horizontal">
	    		 <div class="form-group">
				    <label class="col-xs-2 col-sm-3 col-md-4 col-lg-4 control-label">旧&nbsp; 密&nbsp; 码</label>
				    <div class="col-xs-7 col-sm-6 col-md-5 col-lg-5">
				      <input value="" name="aaa" type="text" class="form-control" />
				    </div>
				    <span class="col-xs-3 col-sm-3 col-md-3 col-lg-3 margin-top" id="jiu"></span>
				 </div>
				 <div class="form-group">
				    <label class="col-xs-2 col-sm-3 col-md-4 col-lg-4 control-label">手&nbsp; 机&nbsp; 号</label>
				    <div class="col-xs-7 col-sm-6 col-md-5 col-lg-5">
				      <div class="input-group btn-group">
						<input type="text" name="hUserphone" class="form-control">
						<span class="input-group-btn">
							<button type="button" class="btn" id="ph">获取验证码</button>
						</span>
					  </div>
				    </div>
				    <span class="col-xs-3 col-sm-3 col-md-3 col-lg-3 margin-top" id="shoujihao"></span>
				 </div>
				 <div class="form-group">
				    <label class="col-xs-2 col-sm-3 col-md-4 col-lg-4 control-label">验&nbsp; 证&nbsp; 码</label>
				    <div class="col-xs-7 col-sm-6 col-md-5 col-lg-5">
				      <input value="" name="Yanzheng" type="text" class="form-control" />
				    </div>
				    <span class="col-xs-3 col-sm-3 col-md-3 col-lg-3 margin-top" id="Y"></span>
				 </div>
				  <div class="form-group">
				    <label class="col-xs-2 col-sm-3 col-md-4 col-lg-4 control-label">新&nbsp; 密&nbsp; 码</label>
				    <div class="col-xs-7 col-sm-6 col-md-5 col-lg-5">
				      <input  value="" name="hUserpassword" type="text" class="form-control"/>
				    </div>
				    <span class="col-xs-3 col-sm-3 col-md-3 col-lg-3 margin-top" id="x"></span>
				 </div>
				 <div class="form-group">
				    <label class="col-xs-2 col-sm-3 col-md-4 col-lg-4 control-label"></label>
				    <div class="col-xs-7 col-sm-6 col-md-5 col-lg-5">
				      <input name="" type="button" id="queding" class="btn btn-primary" value="确认保存"/>&nbsp;&nbsp;&nbsp;
				      <input onclick="location.href='back/infoBody'" type="button" class="btn btn-primary" value="返回上一页"/>
				    </div>
				 </div>
	    	</form>
    </div>
</body>
</html>
